home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13457 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: howland.reston.ans.net!psinntp!psinntp!psinntp!psinntp!usenet
  2. From: grantp@usa.pipeline.com(Pete Grant)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Many instance of a class
  5. Date: 26 Mar 1996 09:46:39 GMT
  6. Organization: Kalevi, Inc.
  7. Message-ID: <4j8edv$ges@news1.h1.usa.pipeline.com>
  8. References: <4j7b28$8d4@athena.ulaval.ca>
  9. NNTP-Posting-Host: 38.8.60.2
  10. X-PipeUser: grantp
  11. X-PipeHub: usa.pipeline.com
  12. X-PipeGCOS: (Pete Grant)
  13. X-Newsreader: Pipeline v3.5.0
  14.  
  15. On Mar 25, 1996 23:50:51 in article <Many instance of a class>,
  16. 'duchen00@gel.ulaval.ca (Francois Duchene)' wrote: 
  17.  
  18.  
  19. >Hi everyone 
  20. >I am currently writing an object oriented program with Visual 
  21. >C++ 
  22. >and I have a problem with classes and variables scope : 
  23. >I have four different classes. Three of them have member functions 
  24. >that must 
  25. >be able to access all member variables of the fourth class (let's call 
  26. >it 
  27. >"range").  The problem is that I need a hundread instances of  the 
  28. >"range" 
  29. >class.  
  30. >I want to be able to access any member variable of an instance of 
  31. >"range" 
  32. >from within any of the three others classes (member functions).  
  33. >How can I do this? 
  34. >Thanks for any answer. 
  35. >Francois Duchene 
  36. >duchen00@gel.ulaval.ca 
  37. >N.B.: Please E-MAIL me since I don't read this group on a regular 
  38. >basis. 
  39.  
  40. Make the fourth class a friend of the others. 
  41.  
  42. There are exceptions to every rule; however, generally, it 
  43. is a possible design flaw if a class needs to give blanket 
  44. authority to another to access its innards.  The fact that 
  45. you have three such classes raises the probability.  Look 
  46. again at your design and see if you can't deal with this 
  47. situation another way.  
  48.  
  49. BTW, The number of instances is irrelevant in this case. 
  50. A hundred instances of a class isn't many. 
  51.  
  52. -- 
  53. Pete Grant 
  54. Kalevi, Inc. 
  55. Software Engineering & development
  56.